home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Delphi Informant Complete 1995 - 2000
/
Delphi Informant Complete 1995 to 2000.iso
/
Delphi Informant Magazine Complete Works SOURCE CODE 1998.rar
/
1998
/
Nov
/
di9811gd
/
Example3
/
DllCode.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1998-03-10
|
1KB
|
69 lines
unit DllCode;
interface
uses Windows, Dialogs, SysUtils, Forms;
type
TTestObject = class(TObject)
public
ObjectName: String;
constructor Create;
end;
procedure DllShowMessage(Msg: String);
threadvar
tlObject: TTestObject;
const
MessageBoxTitle = 'Dll3';
CRLF = #13 + #10;
implementation
procedure DllShowMessage(Msg: String);
begin
MessageBox(GetDesktopWindow, PChar(Msg), MessageBoxTitle,
MB_OK or MB_SETFOREGROUND or MB_TASKMODAL);
end;
{ TTestObject }
constructor TTestObject.Create;
begin
ObjectName := 'Test Object: ' + IntToStr(GetCurrentThreadID);
end;
procedure DllEntry(Reason: Integer);
begin
case Reason of
DLL_THREAD_ATTACH: begin
tlObject := TTestObject.Create;
DllShowMessage(tlObject.ObjectName);
end;
DLL_THREAD_DETACH: begin
if (tlObject = nil) then
DllShowMessage('Object is nil.')
else
DllShowMessage(tlObject.ObjectName);
tlObject.Free;
end;
end;
end;
initialization
IsMultiThread := True;
DllProc := @DllEntry;
tlObject := TTestObject.Create;
finalization
if (tlObject = nil) then
DllShowMessage('Object is nil.')
else
DllShowMessage(tlObject.ObjectName);
tlObject.Free;
end.